<script type="text/javascript">
	$(function() {

	    
	    $.fn.dataGridOptions.addBorrowFormSubFun("#form",'/modules/additional/finanFlow/doAddFlow.html');

	    $('#changetoDay').click(function(){
			if(!$('#borrow_day').is(":animated")){
				var borrowTimeType=$('#borrowTimeType').val();
				if(borrowTimeType==0){
					$(this).addClass("dayhover")
					$('#borrowTimeType').val('1');
					$('#time_limit_day_box').html('<@linkage name="timeLimit" id="time_limit_day" class="select_low"  type="value" nid="borrow_time_limit_day"/>');
					$('#time_limit_day').addClass("J_input")
					$('#time_limit_box').html('')
					$('#style').html('<option value="2">一次性还款</option>');
					$('#changetoDay').html('按月');
				}else if($("#typeId").val()!=101){
					$(this).removeClass("dayhover")
					$('#borrowTimeType').val('0');
					$('#time_limit_day_box').html('')
					$('#time_limit_box').html('<@linkage name="timeLimit" id="time_limit" class="J_input select_low" type="value" nid="borrow_time_limit"/>')
					$('#time_limit').addClass("J_input");
					$('#time_limit').show();
					$('#style').html('<option value="2">一次性还款</option>');
					$('#changetoDay').html('按天');
				}
				borrowTimeType=$('#borrowTimeType').val();
			}
	    });
	});
	
	 function checkMoney(){
		 var money = parseInt($("#account").val()); //项目金额
		 var eachMoney = parseInt($("#eachMoney").val()); //每份金额
		 var startCope =  parseInt($("#startCopies").val());//起投金额
		 var totalCopie =  parseInt($("#accountCopies").val()); //总份数
		 if(money ==0  || eachMoney ==0 ){
			 return;
		 }else{
			 var isCoun = money % eachMoney;
			 if(isCoun >0 ){
				 alert("项目金额不是每份金额的整数倍");
				 $("#account").val('0');
				 $("#eachMoney").val('0');
			 }else{
				 var totalCount = money / eachMoney
				 $("#accountCopies").val(totalCount);
				 checkstart();
			 }
			
		 }
	 }
	 
	 function checkstart(){
		 var startCope =  parseInt($("#startCopies").val());//起投金额
		 var totalCopie =  parseInt($("#accountCopies").val()); //总份数
		 if(totalCopie ==0 || startCope ==0){
			return ; 
		 }
		 if(startCope>totalCopie){
			 alert("起始申购份数不能大于项目总份数");
		 }
	 }
	 
	 //	输入框要求必须为整数数字
	 $('.int_figure_required').bind('keyup blur', function() {			
        // 不能输入 类似00、01、0000001的数值
  	  	if($(this).val().match(/^0+\d+/)){
            this.value = $(this).val().replace(/^0+(\d+)/, '$1');
        }
	}); 
</script>
<form id="form" method="post" enctype="multipart/form-data">
	<div class="borrowForm" style="border-top:none;">
		<h1 class="borrowFormTitle">【标设置】</h1>
	    <div class="borrowSetting">
	        <input type="radio" class="radio" id="specal1" name="category" value="1" checked>
	        <label for="specal1">理财</label>
	        
	    </div>
	
    
	<h1 class="borrowFormTitle">基本信息</h1>
	<ul>
		
		<li><span>项目标题：</span><input type="text" name="name" autocomplete="off" maxlength="25" class="borrowFormTxt easyui-validatebox" data-options="required: true,validType:'maxLength[25]'" /></li>
		<li><span>借款人邮箱：</span><input type="text" name="email" id="email" autocomplete="off" size="15" class="borrowFormTxt2 easyui-validatebox" data-options="required: true,validType:'email'" /><input type="button" value="选择" onclick="showMail()" class="selectEmail" /></li>
	
		<li><span>项目总金额：</span><input type="text" name="account" id="account" value="0" onblur="checkMoney()" autocomplete="off" onkeyup="value=value.replace(/\D/g,'')" onkeydown="value=value.replace(/\D/g,'')" size="15" class="int_figure_required borrowFormTxt1 easyui-validatebox" data-options="required: true,validType:['numOnly','accout[500,5000000]']"><em>元</em></li>
		<li><span>项目年利率：</span><input type="text" name="apr"  autocomplete="off" size="15" class="borrowFormTxt1 easyui-validatebox int_figure_required"  style="width:60px" onkeyup="value=value.replace(/\D/g,'')" maxlength="5" data-options="required: true,validType:'apr[1,24]'"><em>%</em></li>
		<li><span>每份金额：</span><input type="text" name="eachMoney" value="0" id="eachMoney" onblur="checkMoney()" autocomplete="off" onkeyup="value=value.replace(/\D/g,'')" size="15" class="int_figure_required borrowFormTxt1 easyui-validatebox" data-options="required: true,validType:['numOnly','accout[50,10000]']"><em>元</em></li>
		<li><span>起投份数：</span><input type="text" name="startCopies" id="startCopies"  onblur="checkMoney()" autocomplete="off" onkeyup="value=value.replace(/\D/g,'')" size="15" class="int_figure_required borrowFormTxt1 easyui-validatebox" data-options="required: true,validType:['numOnly']"><em>份</em></li>
		<li><span>总份数：</span><input type="text" name="accountCopies"  id="accountCopies"  autocomplete="off" onkeyup="value=value.replace(/\D/g,'')" id="totalCount" value="0" class="int_figure_required borrowFormTxt1 easyui-validatebox" disabled="disabled"><em>份</em></li>
		<br/><p></p>
		<li><span>是否天标：</span><input type="checkbox" id="changetoDay" class="day_chose" name="isDay" value="1"></li>
		<li><span>借款期限：</span>
			
	        <label id="time_limit_box"><@linkage name="timeLimit" id="time_limit" class="J_input select_low" type="value" nid="borrow_time_limit"/></label>
	        <label id="time_limit_day_box"></label>
	
		</li>
		<li id="borrow_day" style="display:none;">
			<span>是否天标：</span><input type="hidden" name="borrowTimeType" id="borrowTimeType" value="0" />
			<input type="checkbox" checked="checked" disabled="disabled">
		</li>
		<li>
			<span>还款方式：</span>
		
			<select name="repayStyle" id="style" class="borrowFormTxt">
				<option value="2">一次性还款</option>
			</select>
		
		</li>

		<input name="addFlowToken" value="${addFlowToken!}" type="hidden"/>
	</ul>
	<div class="borrowFormMuti"><span>项目介绍：</span>
	<#include "../../column/article/umeditor.htm">
	<@showUeditor width=650 heigth=400 id="articleEditor" name="content" content=""/>
	</div>
</div>

<div class="borrowForm">
	<h1 class="borrowFormTitle">证明资料图</h1>
    <div id="uploadGuaranteeBox" class="uploadWrap" data-arr="uploadFile">
        <ul id="borrowPagePic" class="photoUpload">
            <li class="addFileBtn">
              <input type="file" name="file" class="uploadFileInput" id="uploadFile" onchange="return ajaxFileUpload1('uploadFile','/imageUp.jsp?editorid=borrow','picPath');" title="点击上传图片" />
            </li>
        </ul>
   </div>	
</div>



<div class="borrowForm">
	<h1 class="borrowFormTitle">借款缩略图</h1>
    <div id="uploadThumbnailBox" class="uploadWrap" data-arr="uploadThumbnailFile">
        <ul id="borrowThumbnailPic" class="photoUpload">
            <li class="addFileBtn">
              <input type="file" name="thumbnailFile" class="uploadFileInput" id="uploadThumbnailFile" onchange="return ajaxFileUpload3('uploadThumbnailFile','/imageUp.jsp?editorid=borrow','thumbnailPicPath');" title="点击上传图片" />
            </li>
        </ul>
   </div>	
</div>


</form>
<script type="text/javascript">seajs.use("${theme_dir}/js/ajaxfileupload");seajs.use("${theme_dir}/js/upload");</script>
<script type="text/javascript">seajs.use("/plugins/layer/layer.min");seajs.use("/plugins/layer/skin/layer.css");</script>
<!-- 图片预览-->
<script type="text/javascript">
	$(".fileshow").fancybox();
	$('.l-btn-text').click(function(){
	  if($("#borrowPagePic li").length<=1){
		  layer.alert('请上传图片资料', 8);
		  return false;
	  }

	  // 功能 #465 后台发标的时候，缩略图改为不是必输项
	  /*
	  if($("#borrowThumbnailPic li").length<=1){
		  layer.alert('请上传缩略图', 8);
		  return false;
	  }
	   */
	})
</script>

